package dl.bukkit.myststus.logger;

import dl.bukkit.myststus.configuration.imp.Config;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;

public class Logger {
    private Logger() {
    }

    public static void message(CommandSender sender, Object... messages) {
        if (messages != null) {
            sender.sendMessage(append(messages));
        }
    }

    public static void prefixMessage(CommandSender sender, Object... messages) {
        if (messages != null) {
            sender.sendMessage("§6§l[§b§lM§a§l-§d§lS§6§l] " + append(messages));
        }
    }

    public static void consoleMessage(Object... messages) {
        if (messages != null) {
            prefixMessage(Bukkit.getConsoleSender(), messages);
        }
    }

    public static void debug(Object... objects) {
        if (Config.getInst().getBoolean("Setting.Debug")) {
            Bukkit.getConsoleSender().sendMessage("§6§l[§b§lM§a§l-§d§lS§6§l] " + "§6[调式] " + append(objects));
        }
    }

    public static void pluginInfo() {
        consoleMessage("§a插件启动完成!");
        consoleMessage("§a作者: DogLong QQ: 2456261179");
    }

    private static String append(Object... objs) {
        StringBuilder builder = new StringBuilder();
        for (Object obj : objs) {
            builder.append(obj);
        }
        return builder.toString().replaceAll("&", "§");
    }

}
